/*
 * @Author: zhangweixin 
 * @Date: 2018-11-14 09:50:34 
 * @Last Modified by:   zhangweixin 
 * @Last Modified time: 2018-11-14 09:50:34 
 */
const webpackDevServer = require('webpack-dev-server');
const webpack = require('webpack');
const path = require('path');
const config = require('./webpack.node.hmr.js');
const options = {
  contentBase: path.join(__dirname, './dist'),
  hot: true, 
  host: 'localhost'
};

webpackDevServer.addDevServerEntrypoints(config, options);
//webpack-dev-server中具自带方法，他能添加 HMR的入口点
const compiler = webpack(config);
const server = new webpackDevServer(compiler, options);
//将dev服务器选项放在webpack配置对象，作为第二个参数传递
server.listen(3000, 'localhost', () => {
  console.log('dev server listening on port 3000');
  //监听3000端口
});